package java08;
//定义一个继承Thread线程子类
//这种售票方法不合理
class TicketWindow extends Thread{
    private int tickets = 100;
    @Override
    public void run() {
        while(true){
            if(tickets > 0){
                System.out.println(Thread.currentThread().getName() + "正在发售第" + tickets-- + "张票");
            }else{
                return;
            }
        }
    }
}
public class ThreadTest02 {
    public static void main(String[] args){
        //分别创建4个线程对象TicketWindow并开启，来模拟4个售票窗口
        new TicketWindow().start();
        new TicketWindow().start();
        new TicketWindow().start();
        new TicketWindow().start();
    }
}
